﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers
{
    /// <summary>
    /// 用户模块
    /// </summary>
    [Route("api/user")]
    public class UserController : Controller
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userId" require="true">账号</param>
        /// <param name="userPwd">密码</param>
        /// <returns></returns>
        [HttpPost("login")]
        public ActionResult<Model.Result<Model.ApiResult.UserResult.UserLoginResult>> UserLogin(string userId, string userPwd)
        {

            return Json(new BLL.Manage.UserManage().UserLogin(userId, userPwd));
        }

        /// <summary>
        /// 用户获取用户信息
        /// </summary>
        /// <returns></returns>
        [HttpPost("userinfo")]
        public ActionResult<Model.Result<Model.ApiResult.UserResult.UserInfoResult>> GetUserInfo()
        {
            var info = new BLL.Manage.UserManage().GetUserInfo();
            if (info != null)
            {
                return Json(RestfulAPIModel.SuccessReult<Model.ApiResult.UserResult.UserInfoResult>(info));
            }
            else
            {
                return Json(RestfulAPIModel.ErrorReult<Model.ApiResult.UserResult.UserInfoResult>());
            }
        }
    }
}
